
<#include "header.ftl">

  <!-- 内容区域 -->
<div class="tpl-content-wrapper">

   <div class="container-fluid am-cf">
                <div class="row">
                   <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                        <ol class="am-breadcrumb">
						  <li><a href="${Domain}my" class="am-icon-home">首页</a></li>
						  <li ><a href="${Domain}my/question/list/${question.type}"><#if question.type=0>判断</#if><#if question.type=1>单选</#if><#if question.type=2>多选</#if><#if question.type=3>填空</#if><#if question.type=4>自填</#if></a></li>
						  <li class="am-active">选项</li>
						</ol>
                    </div>
                  	<#include "../common/return.ftl">
                </div>
</div>
  <div class="row-content am-cf">
  
  

          <div class="row">

                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">${question.name}</div>
                                <div class="widget-function am-fr">
                                <#if !(question.type==3&&list?size gt 0) >
                                    <a href="${Domain}my/question/answeradd/${question.id}?url=${url}" class="am-icon-plus"    data-am-popover="{theme: 'success sm',content: '新增选项', trigger: 'hover focus'}"></a>
                                </#if>
                                </div>
                            </div>
                            <div class="widget-body am-fr">
							<div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                                    ${question.tag} ${question.title}
                               </div>
							<div class="am-u-sm-12">
  
                                <div class="am-scrollable-horizontal">
                                
                                    <table width="100%" class="<#include "../common/table-class.ftl">"  >
											    <thead>
											        <tr>
											           
											            <th>名称</th>
											            <th>值</th>
											            <#if question.type!=3>
											             <th>排序</th>
											             </#if>
											             <th width="150px">操作</th>
											        </tr>
											    </thead>
											    <tbody>
											    
											    	
											    	<#list list as item>
											        <tr>
											           
											            <td>${item.name}</td>
											            <td>${item.value}</td>
											            <#if question.type!=3>
											            <td>${item.seq}</td>
											            </#if>
											            <td>
											            <div class="tpl-table-black-operation">
											            <#if question.type!=3>
                                                        <a href=" javascript:prompt(${item.id},'${item.name}',${item.seq})">
                                                            <i class="am-icon-pencil"></i> 调整排序
                                                        </a>
                                                        </#if>
                                                         <a href="javascript:deleteItem(${item.id},'${item.name}')" class="tpl-table-black-operation-del">
                                                            <i class="am-icon-trash-o"></i> 删除
                                                        </a>
                                                        </div>
											            </td>
											        </tr>
											        </#list>
											    </tbody>
											</table>  
								</div>
							</div>
                              
                            </div>
                        </div>
                    </div>
                </div>
        
         
        
            
   </div>
</div>   



<div class="am-modal am-modal-prompt" tabindex="-1" id="my-prompt">
   <input type="hidden" id="id" name="id" value="">
  <div class="am-modal-dialog">
     <div class="am-modal-hd">
      <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
    </div>
    <div class="am-modal-bd">
      <input type="number"  id="seq" value="" class="am-modal-prompt-input">
    </div>
    <div class="am-modal-footer">
      <span class="am-modal-btn" data-am-modal-cancel>取消</span>
      <span class="am-modal-btn" data-am-modal-confirm>提交</span>
    </div>
  </div>
</div>

     
 <script type="text/javascript">
 var loading;
 function prompt(id,name,seq)
 {
    //清除缓存
     $("#seq").val(seq); $("#id").val(id);
	 $('#my-prompt').modal({
	      onConfirm: function(e) {
	        var id=$("#id").val();
	        var seq=e.data;
	        $.post("${Domain}api/question/seq", { id: id, seq: seq },
			   function(json){
			      	if(json.status)
			    	{
			    	  	if(loading)loading.hide();
			    		weui.toast("修改成功！"); 			    		
	
			    		location.href="";		
			    		
			    	}else
			    	{	
			    		if(loading)loading.hide();
			    	    weui.alert(json.msg);  		 
			    	}
			   });
	        
	      },
	      onCancel: function(e) {	  
	      }
	  });
	    	 
	    
 }
 
 function deleteItem(id,name)
 {
 	weui.confirm('是否删除{'+name+'}选项?', 
 	function(){ 
 	   loading =weui.loading('数据删除中...');
 		$.getJSON("${Domain}api/question/answerdelete", { id: id }, function(json){
		  if(json.status)
		  {
		     if(loading) loading.hide();
	    	 weui.toast(json.msg);
	    	 location.href="";	
		  }else
	    	{	
	    		if(loading) loading.hide();
	    	    weui.alert(json.msg);  		 
	    	}
		});
 	  },
    function(){ console.log('no') });
 }
 </script>  

<#include "footer.ftl">